package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ResultManagement;
import com.ruoyi.system.service.IResultManagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 四级联考终审结果Controller
 * 
 * @author ruoyi
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/system/result")
public class ResultManagementController extends BaseController
{
    @Autowired
    private IResultManagementService resultManagementService;

    /**
     * 查询四级联考终审结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:result:list')")
    @GetMapping("/list")
    public TableDataInfo list(ResultManagement resultManagement)
    {
        startPage();
        List<ResultManagement> list = resultManagementService.selectResultManagementList(resultManagement);
        return getDataTable(list);
    }

    /**
     * 导出四级联考终审结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:result:export')")
    @Log(title = "四级联考终审结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResultManagement resultManagement)
    {
        List<ResultManagement> list = resultManagementService.selectResultManagementList(resultManagement);
        ExcelUtil<ResultManagement> util = new ExcelUtil<ResultManagement>(ResultManagement.class);
        util.exportExcel(response, list, "四级联考终审结果数据");
    }

    /**
     * 获取四级联考终审结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:result:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(resultManagementService.selectResultManagementById(id));
    }

    /**
     * 新增四级联考终审结果
     */
    @PreAuthorize("@ss.hasPermi('system:result:add')")
    @Log(title = "四级联考终审结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ResultManagement resultManagement)
    {
        return toAjax(resultManagementService.insertResultManagement(resultManagement));
    }

    /**
     * 修改四级联考终审结果
     */
    @PreAuthorize("@ss.hasPermi('system:result:edit')")
    @Log(title = "四级联考终审结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ResultManagement resultManagement)
    {
        return toAjax(resultManagementService.updateResultManagement(resultManagement));
    }

    /**
     * 删除四级联考终审结果
     */
    @PreAuthorize("@ss.hasPermi('system:result:remove')")
    @Log(title = "四级联考终审结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(resultManagementService.deleteResultManagementByIds(ids));
    }

    /**
     * 获取四级联考终审结果统计数据
     */
    @PreAuthorize("@ss.hasPermi('system:result:list')")
    @GetMapping("/statistics")
    public AjaxResult getStatistics()
    {
        return success(resultManagementService.getResultStatistics());
    }
}
